package com.cmower.mkyong;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class TestToMap {
    public static void main(String[] args) {

//        List<Pair<String, Double>> pairArrayList = new ArrayList<>(3);
//        pairArrayList.add(new Pair<>("version", 6.19));
//        pairArrayList.add(new Pair<>("version", 10.24));
//        pairArrayList.add(new Pair<>("version", 13.14));
//        Map<String, Double> map = pairArrayList.stream().collect(
//// 生成的 map 集合中只有一个键值对：{version=13.14}
//                Collectors.toMap(Pair::getKey, Pair::getValue, (v1, v2) -> v2));


String[] departments = new String[] {"沉默王二", "沉默王二", "沉默王三"};
Map<Integer, String> map = Arrays.stream(departments)
        .collect(Collectors.toMap(String::hashCode, str -> str, (v1, v2) -> v2));
System.out.println(map);
    }
}
